#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<stdlib.h>
#include<unistd.h>
#define _SIZE 1024
int main()
{
    int pipefd[2] = {0};
    int r = pipe(pipefd);
    if(r < 0)
    {
        perror("pipe");
        exit(1);
    }
    pid_t n = fork();
    if(n < 0)
    {
        perror("fork");
        exit(2);
    }
    if(n == 0)
    {
        close(pipefd[1]);
        char str1[_SIZE] = {"\0"};       
        read(pipefd[0],str1,sizeof(str1));
        str1[sizeof(str1)] = '\0';
        write(1, str1, sizeof(str1));
        close(pipefd[0]);
    }
    close(pipefd[0]);
    char str[_SIZE] = {"i am father\n"};
    write(pipefd[1], str, sizeof(str));
    close(pipefd[1]);
    return 0;
}